package view.model;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import model.Medicament;

/**
 *
 * @author BACQ Justine et SACRE Sauvane
 */

public class TableModelMedoc extends AbstractTableModel{
    private List<String> columnNames = new ArrayList<String>();
    private List<Medicament> contents = new ArrayList<Medicament>();
    public TableModelMedoc (List<Medicament> medicamentPourSoin ){
        contents = medicamentPourSoin;
        columnNames.add("Identifiant");
        columnNames.add("Nom");
    }
    
     public int getColumnCount(){
        return columnNames.size();
    }
    
    public int getRowCount(){
        return contents.size();
    }
    
    public String getColumnName(int col){
        return columnNames.get(col);
    }
    
    public Medicament getValueAtRow(int row){
        return contents.get(row);
    }
    
    public Object getValueAt (int row, int col){
        Medicament medocSession  = contents.get(row);
        switch(col){
            case 0 : return medocSession.getIdMedicament();
            case 1 : return medocSession.getNomMedicament();
            default : return null;
        }
    }       
    public Class getColumnClass(int col){
        Class c;
        switch(col){
            case 0 : c = String.class;
            case 1 : c = String.class;
                default : c = String.class;
        }
        return c;
    }
 }

